﻿<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
    protected string Notice = "";
    protected double[] JH=new double[24];
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            string ys=this.Request.QueryString["y"];
            string ms = this.Request.QueryString["m"];
            int y=0,m=0;
            if (ys != null && ms != null)
            {
                int.TryParse(ys,out y);
                int.TryParse(ms, out m);
            }

            if (y == 0)
            {
                y = DateTime.Today.Year;
            }
            if (this.NianDu.Items.FindByText(y.ToString()) == null)
            {
                ListItem li = new ListItem(y.ToString());
                this.NianDu.Items.Add(li);
            }
            this.NianDu.Text = y.ToString();
            this.YueFen.Text = m.ToString();
        }
        SqlDataSource1.Select(DataSourceSelectArguments.Empty);
    }

    protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
    {
        for (int i = 0; i < 24; i++)
        {
            if (!Convert.IsDBNull(e.Command.Parameters[i+2].Value))
            {
                this.JH[i] = (double)e.Command.Parameters[i + 2].Value;
            }
        }
        
    }
</script>
<html>
<head></head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
 ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
 SelectCommand="SELECT
@一分厂产品1=一分厂产品1
,@一分厂产品2=一分厂产品2
,@一分厂产品3=一分厂产品3
,@一分厂产品4=一分厂产品4
,@二分厂产品1=二分厂产品1
,@二分厂产品2=二分厂产品2
,@二分厂产品3=二分厂产品3
,@二分厂产品4=二分厂产品4
,@三分厂产品1=三分厂产品1
,@三分厂产品2=三分厂产品2
,@三分厂产品3=三分厂产品3
,@三分厂产品4=三分厂产品4
,@四分厂产品1=四分厂产品1
,@四分厂产品2=四分厂产品2
,@四分厂产品3=四分厂产品3
,@四分厂产品4=四分厂产品4
,@五分厂产品1=五分厂产品1
,@五分厂产品2=五分厂产品2
,@五分厂产品3=五分厂产品3
,@五分厂产品4=五分厂产品4
,@外购接箍1=外购接箍1
,@外购接箍2=外购接箍2
,@外购接箍3=外购接箍3
,@外购接箍4=外购接箍4
FROM 生产计划 where 年度=@年度 and 月份=@月份"
onselected="SqlDataSource1_Selected"
>
<SelectParameters>
<asp:ControlParameter Name="年度" DbType="Int32" Size="4" ControlID="NianDu" />
<asp:ControlParameter Name="月份" DbType="Int32" Size="4" ControlID="YueFen" />
<asp:Parameter Name="一分厂产品1" DbType="Double" Size="8" Direction="Output" />
<asp:Parameter Name="一分厂产品2" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="一分厂产品3" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="一分厂产品4" DbType="Double" Size="8" Direction="Output"/>

<asp:Parameter Name="二分厂产品1" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="二分厂产品2" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="二分厂产品3" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="二分厂产品4" DbType="Double" Size="8" Direction="Output"/>

<asp:Parameter Name="三分厂产品1" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="三分厂产品2" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="三分厂产品3" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="三分厂产品4" DbType="Double" Size="8" Direction="Output"/>

<asp:Parameter Name="四分厂产品1" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="四分厂产品2" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="四分厂产品3" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="四分厂产品4" DbType="Double" Size="8" Direction="Output"/>

<asp:Parameter Name="五分厂产品1" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="五分厂产品2" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="五分厂产品3" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="五分厂产品4" DbType="Double" Size="8" Direction="Output"/>

<asp:Parameter Name="外购接箍1" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="外购接箍2" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="外购接箍3" DbType="Double" Size="8" Direction="Output"/>
<asp:Parameter Name="外购接箍4" DbType="Double" Size="8" Direction="Output"/>
</SelectParameters>
</asp:SqlDataSource>

<asp:Label ID="Label_Ignore" runat="server" Text="0" Visible="false"></asp:Label>

<div id="wintop" class="wintop">生产计划明细</div>
    <asp:Panel ID="Panel1" runat="server" CssClass="panel">
年 度：<asp:DropDownList ID="NianDu" runat="server" Width="80px" AutoPostBack="true">
    <asp:ListItem>2008</asp:ListItem>
    <asp:ListItem>2009</asp:ListItem>
    <asp:ListItem>2010</asp:ListItem>
    <asp:ListItem>2011</asp:ListItem>
    <asp:ListItem>2012</asp:ListItem>
    <asp:ListItem>2013</asp:ListItem>
    <asp:ListItem>2014</asp:ListItem>
    <asp:ListItem>2015</asp:ListItem>
    <asp:ListItem>2016</asp:ListItem>
    <asp:ListItem>2017</asp:ListItem>
    <asp:ListItem>2018</asp:ListItem>
    <asp:ListItem>2019</asp:ListItem>
    <asp:ListItem>2020</asp:ListItem>
</asp:DropDownList>

月 份：<asp:DropDownList ID="YueFen" runat="server" Width="80px" AutoPostBack="true">
    <asp:ListItem Value="0">年度</asp:ListItem>
    <asp:ListItem Value="1">1月份</asp:ListItem>
    <asp:ListItem Value="2">2月份</asp:ListItem>
    <asp:ListItem Value="3">3月份</asp:ListItem>
    <asp:ListItem Value="4">4月份</asp:ListItem>
    <asp:ListItem Value="5">5月份</asp:ListItem>
    <asp:ListItem Value="6">6月份</asp:ListItem>
    <asp:ListItem Value="7">7月份</asp:ListItem>
    <asp:ListItem Value="8">8月份</asp:ListItem>
    <asp:ListItem Value="9">9月份</asp:ListItem>
    <asp:ListItem Value="10">10月份</asp:ListItem>
    <asp:ListItem Value="11">11月份</asp:ListItem>
    <asp:ListItem Value="12">12月份</asp:ListItem>
</asp:DropDownList> 
    <input type="button" value="导出报表" class="button" onclick="Export();"/>
    <input type="button" value="关 闭" class="button" onclick="parent.swin2_close();" />

</asp:Panel>

<div id="Panel2" class="panel3">
<style type="text/css">
tr{height:30px}
td{text-align:center; font-family:宋体;font-size:12pt;}
td.s0{border:.5pt solid #000000;}
td.s1{border:.5pt solid #000000;border-bottom:1pt double #000000;}
br{mso-data-placement:same-cell;}
</style>
<table border="0" width="1020" cellpadding="0" cellspacing="0" style="border-collapse:collapse;">
<col width="100" />
<col width="100" />
<col width="60" />
<col width="140" />
<col width="80" />
<col width="100" />
<col width="100" />
<col width="100" />
<col width="150" />
<tr>
<td colspan="9" height="70" style="font-size:24pt;"><b><%=this.NianDu.Text %>年<%=this.YueFen.SelectedItem.Text %>生产计划明细</b></td>
</tr>
<tr>
<td class="s0" colspan="2"><b>名 称</b></td>
<td class="s0"><b>钢级</b></td>
<td class="s0"><b>规格(mm)</b></td>
<td class="s0"><b>螺纹形式</b></td>
<td class="s0"><b>技术条件</b></td>
<td class="s0" colspan="2"><b>计划产量(吨)</b></td>
<td class="s0"><b>备 注</b></td>
</tr>
<tr>
<td class="s0" colspan="6" style="text-align:left;"><b>　一、油/套管计划</b></td>
<td class="s0" colspan="2"><%=JH[1] + JH[3] + JH[4] + JH[5] + JH[16]%></td>
<td class="s0"></td>
</tr>

<tr>
<td class="s0" rowspan="2">一分厂</td>
<td class="s0">套管</td>
<td class="s0">J55</td>
<td class="s0">φ139.7×7.72</td>
<td class="s0">LC</td>
<td class="s0">API5CT</td>
<td class="s0" colspan="2"><%=JH[1]%></td>
<td class="s0"></td>
</tr>
<tr>
<td class="s0">套管</td>
<td class="s0">N80</td>
<td class="s0">φ139.7×7.73</td>
<td class="s0">LC</td>
<td class="s0">API6CT</td>
<td class="s0" colspan="2"><%=JH[3]%></td>
<td class="s0"></td>
</tr>

<tr>
<td class="s0" rowspan="3">二分厂</td>
<td class="s0">油管</td>
<td class="s0">J55</td>
<td class="s0"> φ73.1×5.51</td>
<td class="s0">NU</td>
<td class="s0">API6CT</td>
<td class="s0" colspan="2"><%=JH[4]%></td>
<td class="s0"></td>
</tr>
<tr>
<td class="s0">套管</td>
<td class="s0">J55</td>
<td class="s0">φ139.7×7.72</td>
<td class="s0">LC</td>
<td class="s0">API5CT</td>
<td class="s0" colspan="2"><%=JH[5]%></td>
<td class="s0"></td>
</tr>
<tr style="height:24px;">
<td class="s0" colspan="5" style="text-align:right;">二分厂小计：</td>
<td class="s0" colspan="2"><%=JH[4] + JH[5]%></td>
<td class="s0"></td>
</tr>

<tr>
<td class="s0">五分厂</td>
<td class="s0">油管</td>
<td class="s0">J55</td>
<td class="s0">φ73.1×5.51</td>
<td class="s0">NU</td>
<td class="s0">API7CT</td>
<td class="s0" colspan="2"><%=JH[16]%></td>
<td class="s0"></td>
</tr>

<tr style="height:24px;">
<td class="s1" rowspan="2">小计</td>
<td class="s0" colspan="5" style="text-align:right;">油管小计：</td>
<td class="s0" colspan="2"><%=JH[4] + JH[16]%></td>
<td class="s0"></td>
</tr>
<tr style="height:24px;">
<td class="s1" colspan="5" style="text-align:right;">套管小计：</td>
<td class="s1" colspan="2"><%=JH[1] + JH[3] + JH[5]%></td>
<td class="s1"></td>
</tr>

<tr>
<td class="s0" colspan="6" style="text-align:left;"><b>　二、接箍计划</b></td>
<td class="s0"><b>吨</b></td>
<td class="s0"><b>支</b></td>
<td class="s0"></td>
</tr>

<tr>
<td class="s0" rowspan="3">三分厂</td>
<td class="s0">油管接箍</td>
<td class="s0">J55</td>
<td class="s0">φ88.9×12.5</td>
<td class="s0">NU</td>
<td class="s0">API5CT</td>
<td class="s0"><%=JH[8]*2.3%></td>
<td class="s0"><%=JH[8]%></td>
<td class="s0"></td>
</tr>
<tr>
<td class="s0">套管接箍</td>
<td class="s0">J55</td>
<td class="s0">φ153.67×13.5</td>
<td class="s0">LC</td>
<td class="s0">API5CT</td>
<td class="s0"><%=JH[9] * 6.1%></td>
<td class="s0"><%=JH[9]%></td>
<td class="s0"></td>
</tr>
<tr style="height:24px;">
<td class="s0" colspan="5" style="text-align:right;">三分厂小计：</td>
<td class="s0"><%=JH[8] * 2.3 + JH[9] * 6.1%></td>
<td class="s0"><%=JH[8] + JH[9]%></td>
<td class="s0"></td>
</tr>

<tr>
<td class="s1" rowspan="3">外购</td>
<td class="s0">油管接箍</td>
<td class="s0">J55</td>
<td class="s0">成品</td>
<td class="s0">NU</td>
<td class="s0">API5CT</td>
<td class="s0"><%=JH[20] * 2.3%></td>
<td class="s0"><%=JH[20] %></td>
<td class="s0"></td>
</tr>
<tr>
<td class="s0">套管接箍</td>
<td class="s0">J55</td>
<td class="s0">成品</td>
<td class="s0">LC</td>
<td class="s0">API5CT</td>
<td class="s0"><%=JH[21] * 6.1%></td>
<td class="s0"><%=JH[21]%></td>
<td class="s0"></td>
</tr>
<tr style="height:24px;">
<td class="s1" colspan="5" style="text-align:right;">外购小计：</td>
<td class="s1"><%=JH[20] * 2.3 + JH[21] * 6.1%></td>
<td class="s1"><%=JH[20] + JH[21]%></td>
<td class="s1"></td>
</tr>

<tr>
<td class="s0" colspan="6" style="text-align:left;"><b>　三、套管保护器</b></td>
<td class="s0" colspan="2"><b>套</b></td>
<td class="s0"></td>
</tr>
<tr>
<td class="s0">四分厂</td>
<td class="s0">螺纹保护器</td>
<td class="s0"></td>
<td class="s0">5-1/2"</td>
<td class="s0"></td>
<td class="s0"></td>
<td class="s0" colspan="2"><%=JH[13]%></td>
<td class="s0"></td>
</tr>
<tr>
<td class="s0"></td>
<td class="s0"></td>
<td class="s0"></td>
<td class="s0"></td>
<td class="s0"></td>
<td class="s0"></td>
<td class="s0" colspan="2"></td>
<td class="s0"></td>
</tr>

<tr>
<td width="100"></td>
<td width="100"></td>
<td width="60"></td>
<td width="140"></td>
<td width="80"></td>
<td width="100"></td>
<td width="100"></td>
<td width="100"></td>
<td width="150"></td>
</tr>

</asp:Panel>
</form>
<form id="form2" method="post" action="/PageExport.ashx">
<input type="hidden" name="filename" value="生产计划明细.xls" />
<input type="hidden" name="content" value="" />
</form>
<script>
var notice = '<%=this.Notice %>';
if (notice != '') {
    parent.showmsgbox(notice);
}
</script>
<script>
    function Export() {
        form2.content.value =
"<html xmlns:o='urn:schemas-microsoft-com:office:office'\nxmlns:x='urn:schemas-microsoft-com:office:excel'\nxmlns='http://www.w3.org/TR/REC-html40'>\n<head>\n<meta http-equiv=Content-Type content='text/html; charset=utf-8'>\n<style>\n<!--table\n@page\n{mso-header-data:;\nmso-footer-data:;\nmargin:.39in .31in .39in .31in;mso-header-margin:.31in;mso-footer-margin:.31in;\nmso-page-orientation:landscape;\nmso-horizontal-page-align:center;\n}\n-->\n</style>\n<!--[if gte mso 9]><xml>\n<x:ExcelWorkbook>\n<x:ExcelWorksheets>\n<x:ExcelWorksheet>\n<x:Name>生产计划明细</x:Name>\n<x:WorksheetOptions>\n<x:DefaultRowHeight>285</x:DefaultRowHeight>\n<x:Print>\n<x:ValidPrinterInfo/>\n<x:Scale>100</x:Scale>\n<x:PaperSizeIndex>9</x:PaperSizeIndex>\n<x:HorizontalResolution>200</x:HorizontalResolution>\n<x:VerticalResolution>200</x:VerticalResolution>\n</x:Print>\n<x:Selected/>\n<x:Panes>\n<x:Pane>\n<x:Number>3</x:Number>\n<x:ActiveRow>0</x:ActiveRow>\n<x:ActiveCol>0</x:ActiveCol>\n</x:Pane>\n</x:Panes>\n</x:WorksheetOptions>\n</x:ExcelWorksheet>\n</x:ExcelWorkbook>\n</xml><![endif]-->\n</head>\n<body>"
            + document.getElementById("Panel2").innerHTML
            + "</body></html>";
        form2.submit();
    }
</script>

</form>
</body>
</html>